﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09_1对多
{
    public class ArticleCofig : IEntityTypeConfiguration<Article>
    {
        public void Configure(EntityTypeBuilder<Article> builder)
        {
            builder.ToTable("T_Article");
            builder.Property(e=>e.Title).HasMaxLength(100).IsUnicode().IsRequired();
            builder.Property(e=>e.Content).IsUnicode().IsRequired();
            // 查询数据都是要 IsDeleted=false
            builder.HasQueryFilter(e => e.IsDeleted == false);

        }
    }
}
